package com.cssy.base.web;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;





public abstract class BaseController 	<T> {
	
	/**
	 * 管理实体
	 * @param request
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/manager")
	public abstract String manager(HttpServletRequest request, Model model) throws Exception; 
	/**
	 * 查询LIST
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/list")
	public abstract void list(HttpServletRequest request,HttpServletResponse response)throws Exception ;
	
	/**
	 * 编辑新增
	 * @param request
	 * @param id
	 * @param flag
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/operate/{flag}/{id}")
	public abstract String operationForm(HttpServletRequest request,@PathVariable String id,@PathVariable String flag, Model model) throws Exception;
	
	/**
	 * 保存实体
	 * @param request
	 * @param curAP
	 * @param result
	 * @param model
	 * @return
	 * @throws Exception
	 */
	
	@RequestMapping(value = "/save", method = RequestMethod.POST)
	@ResponseBody
	public abstract Map<String, Object> save(HttpServletRequest request,@ModelAttribute @Valid  T curAP,BindingResult result, Model model) throws Exception;
	/**
	 * 删除实体
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/delete")
	@ResponseBody
	public abstract  Map<String, Object> delete(HttpServletRequest request, HttpServletResponse response ,Model model)throws Exception;
	
	
}
